<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:93:"/Users/yandian/work/matian/application/admin/view/bootstrap/codeTool/controllerForWeixin.html";i:1491820686;}*/ ?>
<?php echo "<?php\n" ?>
namespace app\<?php echo $module; ?>\controller;

use app\common\controller\LiteBase;
use app\common\util\Assert;
use app\common\util\DateTimeUtil;
use app\common\util\LoginManager;
use think\Input;

class <?php echo $name; ?> extends LiteBase
{
    public function index()
    {
        return $this->fetch();
    }

    public function save()
    {
        if (IS_POST) {
            try {
                $db = \app\common\model\<?php echo $name; ?>::instance();
                $postData = Input::post();
                $saveData = Assert::notEmpty($postData, [<?php if(is_array($fields)): $i = 0; $__LIST__ = $fields;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;if($vo['field'] != 'id' && $vo['field'] != 'create_time' && $vo['field'] != 'member_id'): ?>'<?php echo $vo['field']; ?>',<?php endif; endforeach; endif; else: echo "" ;endif; ?>]);
                $saveData['create_time'] = DateTimeUtil::now();
                if (LoginManager::isLoginOn()) {
                    $saveData['member_id'] = LoginManager::getLoginUserId();
                } else {
                    $saveData['member_id'] = 0;
                }
                $lastId = $db->add($saveData);
                if ($lastId) {
                    return $this->jsonSuccess('提交成功');
                }
            } catch (\Exception $ex) {
                return $this->jsonFail($ex->getMessage());
            }
        }
        return $this->jsonFail('系统忙');
    }
    public function saveResult()
    {
        return $this->fetch();
    }
    public function workResult()
    {
        $id = Input::get('id') + 0;
        return $this->fetch('failResult');
        //$this->assign('op', 1);
        //$this->assign('m', ValueBag::wrap(\app\common\model\Appointment::instance()->find($id)));
        //return $this->saveResult();
    }
}